/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 */

package com.microsoft.bot.connector.rest;

import com.microsoft.bot.rest.RestException;
import com.microsoft.bot.schema.ErrorResponse;
import okhttp3.ResponseBody;
import retrofit2.Response;

/**
 * Exception thrown for an invalid response with ErrorResponse information.
 */
public class ErrorResponseException extends RestException {
    /**
     * Initializes a new instance of the ErrorResponseException class.
     *
     * @param message  the exception message or the response content if a message is
     *                 not available
     * @param response the HTTP response
     */
    public ErrorResponseException(final String message, final Response<ResponseBody> response) {
        super(message, response);
    }

    /**
     * Initializes a new instance of the ErrorResponseException class.
     *
     * @param message  the exception message or the response content if a message is
     *                 not available
     * @param response the HTTP response
     * @param body     the deserialized response body
     */
    public ErrorResponseException(
        final String message,
        final Response<ResponseBody> response,
        final ErrorResponse body
    ) {
        super(message, response, body);
    }

    /**
     * The HTTP response body.
     * 
     * @return the HTTP response body
     */
    @Override
    public ErrorResponse body() {
        return (ErrorResponse) super.body();
    }
}
